package sanrenxing.dayEnd.backRepertoryTotal.service.impl;


import org.springframework.stereotype.Service;
import sanrenxing.dayEnd.backRepertoryTotal.dao.FunD;
import sanrenxing.dayEnd.backRepertoryTotal.dao.userDao;
import sanrenxing.dayEnd.backRepertoryTotal.domain.Fun;
import sanrenxing.dayEnd.backRepertoryTotal.domain.Rf;
import sanrenxing.dayEnd.backRepertoryTotal.domain.Role;
import sanrenxing.dayEnd.backRepertoryTotal.domain.users;
import sanrenxing.dayEnd.backRepertoryTotal.service.FunBiz;

import javax.annotation.Resource;
import java.util.List;

@Service
public class FunIml implements FunBiz {
    @Resource
    private FunD funD;
    @Resource
    private userDao ud;
    @Override
    public List<Fun> all(users us) {
        return funD.all(us);
    }

    @Override
    public List<Role> rall(int limit, int page) {
        int h=limit*page;
        int y=limit*(page-1);
        return funD.rall(h,y);
    }

    @Override
    public int add(Role us) {
        return funD.add(us);
    }

    @Override
    public int del(int us) {
        ud.dels(us);
        return funD.del(us);
    }

    @Override
    public int update(Role us) {
        return funD.update(us);
    }
    @Override
    public int updates(String us) {
        String [] sj=us.split(",");
        int k=0;
        for (int i=0;i<sj.length;i++){
          k=funD.del(Integer.parseInt(sj[i]));
        }
        return k;
    }

    @Override
    public int count() {
        return funD.count();
    }

    @Override
    public List<Rf> rfal(int ss) {
        return funD.rfal(ss);
    }

    @Override
    public int rdel(int us) {
        return funD.rdel(us);
    }

    @Override
    public int radd(Rf us) {
        return funD.radd(us);
    }

    @Override
    public int rss(String us,int sj) {
        int k=0;
        String [] sk=us.split(",");
        funD.rdel(sj);
        for (int i=0;i<sk.length;i++){
            Rf rf=new Rf();
            rf.setFunId(sk[i]);
            rf.setRoleId(sj);
            k=funD.radd(rf);
        }
        return k;
    }
}
